using System;
using System.Data;
using System.Data.Sql;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using System.Data.SqlClient;
using BILab.Technical.BI.ModelManagement;

using System.Reflection;



namespace BILab.Technical.BI.ModelManagement
{

	public partial class StoredProcedures
	{
		[Microsoft.SqlServer.Server.SqlProcedure]
		public static void MPCreateModel(SqlString MetadataConnectionString ,
										 SqlString MetadataTableName
										)
		{
			SqlPipe pipe = SqlContext.Pipe;

			if (MetadataConnectionString == null || MetadataTableName == null)
			{
				pipe.Send("->MPCreateModel :");
				pipe.Send("Some of your argument are null");
			}
			else
			{
				SqlConnection connection = new SqlConnection("context connection=true");
				CreateTableEngine cte = new CreateTableEngine();

				pipe.Send("->CreateModel starts");
				pipe.Send("Assembly :" + Assembly.GetExecutingAssembly().FullName);
				pipe.Send("   1 - Process starts");

				cte.Process(MetadataConnectionString, MetadataTableName, connection, pipe);

				pipe.Send("   2 - Process Ends");
				pipe.Send("->CreateModel ends");
			}

		}
	};

}
